package com.coollang.smartbra.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.coollang.smartbra.R;

/**
 * @author: Timmy
 * @data: 2017/12/16
 * @Fuction:
 */

public class ActionFinishDialog extends Dialog {

    private final Context mContext;
    private ImageView mIvBack;
    private TextView mTvSportFinish;

    public ActionFinishDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        mContext = context;
    }

    @Override
    public void show() {
        Window window = this.getWindow();

        if (window != null) {

            // 添加动画
            window.setWindowAnimations(R.style.dialog_enter_exit);
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            window.getDecorView().setPadding(0, 0, 0, 0);
            // 以下这两句是为了保证按钮可以水平满屏
            //lp.width = DisplayUtils.dip2px(mContext, 280);
            //lp.height = DisplayUtils.dip2px(mContext, 400);
            // 设置显示位置
            this.onWindowAttributesChanged(lp);

            // 居底
            window.setGravity(Gravity.CENTER);
            // 设置点击外围解散
            this.setCanceledOnTouchOutside(false);
            super.show();
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_action_finish);
        initView();
    }

    private void initView() {
        mIvBack = (ImageView) findViewById(R.id.iv_close);
        mTvSportFinish = (TextView) findViewById(R.id.tv_sport_finish);
        //mBtnShare = (TextView) findViewById(R.id.share);
    }
}
